﻿using System;
using System . Collections . Generic;
using System . Linq;
using System . Text;
using System . Threading . Tasks;
using System . Xml . Linq;
//using UnityEngine;

namespace WenceyWang . RichMan4L . Maps
{
	/// <summary>
	/// 代表地图上的元素
	/// </summary>
	public abstract class MapObject : GameObject
	{
		

		/// <summary>
		/// 元素的起始X值
		/// </summary>
		public virtual long X { get; set; }

		/// <summary>
		/// 元素的起始Y值
		/// </summary>
		public virtual long Y { get; set; }

		/// <summary>
		/// 元素的尺寸
		/// </summary>
		public abstract MapSize Size { get; set; }

		public abstract void UpdateView ( );


		protected override void Dispose ( bool disposing )
		{
			if ( !disposedValue )
			{
				if ( disposing )
				{
					Map . Currnet . Objects . Remove ( this );
				}
			}
			base . Dispose ( disposing );
		}

		/// <summary>
		/// 基于地图资源创建MapObject
		/// </summary>
		/// <param name="resource"></param>
		public MapObject ( XElement resource ) : this ( )
		{
			X = Convert . ToInt64 ( resource . Attribute ( nameof ( X ) ) . Value );
			Y = Convert . ToInt64 ( resource . Attribute ( nameof ( Y ) ) . Value );
		}

		public MapObject ( ) : base ( )
		{

		}
	}
}
